﻿Imports System.Xml
Imports System.IO
Public Class ucDigitador
    Private ds As New DataSet
    Public Event onSelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Public Property GETDIGITADOR As String
        Get
            Return cmbDigitador.SelectedText
        End Get
        Set(value As String)
            cmbDigitador.SelectedText = value
        End Set
    End Property

    Public Property GETINICIAL As String
        Get
            Return cmbDigitador.SelectedValue
        End Get
        Set(value As String)
            cmbDigitador.SelectedValue = value
        End Set
    End Property

    Private Sub carregaDigitador()
        Try
            Dim caminho As String = Nothing
            caminho = Application.StartupPath & "\xml\digitador.xml"
            If Not File.Exists(caminho) Then
                MsgBox("O arquivo digitador.xml não foi gravado para o diretório \ambiente geralaudos\xml")
            Else
                ds.ReadXml(caminho)
            End If
        Catch ex As Exception
            generica.gravaErro(ex)
        End Try
    End Sub

    Private Sub ucDrogas_Load(sender As Object, e As EventArgs) Handles Me.Load

        carregaDigitador()

        With Me.cmbDigitador
            .DisplayMember = "NOME"
            .ValueMember = "INICIAL"
            .DataSource = ds.Tables("DIGITADOR")
            cmbDigitador.SelectedValue = 0
        End With
        cmbDigitador.SelectedIndex = 0
    End Sub
    Private Sub cmbDigitador_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbDigitador.SelectedIndexChanged
        RaiseEvent onSelectedIndexChanged(sender, e)
    End Sub

End Class
